<?php
/**
 * Holds global item information.
 *
 * @author Mark Dohmen.
 */
final class ItemDefinition {
	
	/**
	 * Holds a set of definitions in an Array.
	 */
	private static $itemDefinitions;
	
	/**
	 * Add's a definition to the array.
	 *
	 * @param $itemDefinition
	 */
	final public static function addDefinition(ItemDefinition $itemDefinition) {
		self::$itemDefinitions[$itemDefinition->getId()] = $itemDefinition;
	}
	
	/**
	 * Gets an ItemDefinition by #id.
	 *
	 * @return $itemDefinition/null
	 */
	final public static function forId(int $id) {
		if (self::$itemDefinitions[$id] instanceof ItemDefinition) {
			return (object) self::$ItemDefinitions[$id];
		}
		return NULL;
	}
	
	/**
	 * The item id.
	 */
	private $id;
	
	/**
	 * The name.
	 */
	private $name;
	
	/**
	 * The description.
	 */
	private $description;
	
	/**
	 * Is it stackable or not
	 */
	private $stackable;
	
	/**
	 * Special bonusses.
	 */
	private $bonusses;
	
	/**
	 * Class Constructor..
	 *
	 * @param $id
	 * @param $name
	 * @param $description
	 * @param $stackable
	 * @param $bonusses
	 */
	final public function ItemDefinition(int $id, string $name, string $description, boolean $stackable, array $bonusses) {
		$this->id = $id;
		$this->name = $name;
		$this->description = $description;
		$this->stackable = $stackable;
		$this->bonusses = $bonusses;
	}
	
	/**
	 * Gets the id.
	 *
	 * @return $id
	 */
	final public function getId() {
		return (int) $this->id;	
	}
	
	/**
	 * Gets the name.
	 *
	 * @return $name
	 */
	final public function getName() {
		return (string) $this->name;	
	}
	
	/**
	 * Gets the description.
	 *
	 * @return $description
	 */
	final public function getDescription() {
		return (string) $this->description;	
	}
	
	/**
	 * Gets the stackable boolean.
	 *
	 * @return $stackable
	 */
	final public function getStackable() {
		return (boolean) $this->stackable;
	}
	
	/**
	 * Gets the bonusses.
	 *
	 * @return $bonusses
	 */
	final public function getBonusses() {
		return (array) $this->bonusses;	
	}
}
?>